﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using T3Task5;

namespace T4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string userName = this.txt_Name.Text;
            string passWord = this.txt_Word.Text;
            if (userName == "" || passWord == "")
            {
                MessageBox.Show("用户名和密码不能为空", "信息提示！", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                bool re = false;
                string sql = "select*from Lin where Name='" + userName + "'and Password='" + passWord + "'";
                SqlDataReader dr =DBHelper.Select(sql);

                while (dr.Read())
                {
                    MessageBox.Show("登录成功！");
                    re = true;
                    break;
                }
                if (!re)
                {
                    MessageBox.Show("用户名或密码错误！");
                }
                dr.Close();

            }
        }
    }
}
